﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace yeqw.FrameWork
{
    public static class DateTimeExtensions
    {
        /// <summary>
        /// yyyy-MM-dd HH:mm:ss:fff
        /// </summary>
        /// <param name="input"></param>
        /// <param name="parrtern"></param>
        /// <returns></returns>
        public static string ToFullDateTimeString(this DateTime dateTime)
        {
            return dateTime.ToString("yyyy-MM-dd HH:mm:ss:fff");
        }

        /// <summary>
        /// yyyy-MM-dd HH:mm:ss
        /// </summary>
        /// <param name="input"></param>
        /// <param name="parrtern"></param>
        /// <returns></returns>
        public static string ToAllDateTimeString(this DateTime dateTime)
        {
            return dateTime.ToString("yyyy-MM-dd HH:mm:ss");
        }

        /// <summary>
        /// yyyy-MM-dd
        /// </summary>
        /// <param name="input"></param>
        /// <param name="parrtern"></param>
        /// <returns></returns>
        public static string ToAllDateString(this DateTime dateTime)
        {
            return dateTime.ToString("yyyy-MM-dd");
        }
        /// <summary>
        /// yyyy-MM-dd
        /// </summary>
        /// <param name="input"></param>
        /// <param name="parrtern"></param>
        /// <returns></returns>
        public static string ToChinesDateString(this DateTime dateTime)
        {
            return dateTime.ToString("yyyy年MM月dd日");
        }

        /// <summary>
        /// yyyy-MM-dd HH:mm:ss
        /// </summary>
        /// <param name="input"></param>
        /// <param name="parrtern"></param>
        /// <returns></returns>
        public static string ToAllTimeString(this DateTime dateTime)
        {
            return dateTime.ToString("HH:mm:ss");
        }
        public static string ToFullTimeString(this DateTime dateTime)
        {
            return dateTime.ToString("HH:mm:ss:fff");
        }
        public static string GetChineseTime(this DateTime dateTime)
        {
            if (dateTime.Hour < 12)
            {
                return "上午";
            }
            else if (dateTime.Hour == 12)
            {
                return "中午";
            }
            else if (dateTime.Hour > 12 && dateTime.Hour < 19)
            {
                return "下午";
            }
            else
                return "晚上";
        }
        public static string GetChineseDate(this DateTime dateTime)
        {
            switch (dateTime.DayOfWeek)
            {
                case DayOfWeek.Monday:
                    return "星期一";
                case DayOfWeek.Tuesday:
                    return "星期二";
                case DayOfWeek.Wednesday:
                    return "星期三";
                case DayOfWeek.Thursday:
                    return "星期四";
                case DayOfWeek.Friday:
                    return "星期五";
                case DayOfWeek.Saturday:
                    return "星期六";
                default:
                    return "星期天";
            }
        }
    }
}
